home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
oath.lha
/
oath
/
src
/
minString.cc
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-29
|
54KB
|
2,281 lines
//***************************************************************************/
// OATH :: Object-oriented Abstract Type Hierarchy
//***************************************************************************/
//
// Copyright (C) 1991, 1990 Texas Instruments Incorporated
// Permission is granted to any individual or institution
// to use, copy, modify, and distribute this software,
// provided that this complete copyright and permission notice
// is maintained, intact, in all copies and supporting documentation.
//
// Texas Instruments Incorporated provides this software "as is"
// without express or implied warranty.
//
//***************************************************************************
// minString (minStringA, minStringG, dlMinStringG, pMinStringG)
// minStringPos (minStringPosA, minStringPosG, dlMinStringPosG, pMinStringPosG)
//
// History:
// 07/91 Brian M Kennedy import, export, typeRegister
// 06/91 Brian M Kennedy New macros & format; remove printDiagnostic
// 10/90 Brian M Kennedy Major Rewrite
// 02/90 Brian M Kennedy Original
//
//***************************************************************************/
#include "copyright.h"
#include <oath/minString.h>
#include <stdlib.h>
#include <math.h> /* included because abs() not in stdlib */
#include <iostream.h>
/////////////////////////////////////////////////////////////////////////////
// minString Outlines
OUTLINES(minString, string)
/////////////////////////////////////////////////////////////////////////////
// dlMinStringG Outlines
OUTLINES_G(dlMinString, minString)
// Constructors //////////
dlMinStringG::
dlMinStringG (int IsConst)
:minStringG(IsConst), Header(0), End(0), PosList(0)
{ref();
{End = Header = new dlcNodeP;}
deref();
}
dlMinStringG::
dlMinStringG (const seqG* S, int IsConst)
:minStringG(IsConst), Header(0), End(0), PosList(0)
{ref();
{End = Header = new dlcNodeP;
for(posA P = S->makePos(0, 0); P(); ++P)
{characterA C = characterA::isa(*P);
if(!!C)
End = End->insertAfter(C.guts());
}
}
deref();
}
dlMinStringG::
dlMinStringG (const posG* Start, const posG* Beyond, int IsConst)
:minStringG(IsConst), Header(0), End(0), PosList(0)
{ref();
{End = Header = new dlcNodeP;
if(!Beyond)
{for(posA P = (posA&)Start->makeCopy(0); P(); ++P)
{characterA C = characterA::isa(*P);
if(!!C)
End = End->insertAfter(C.guts());
}
}
else
{ensure(Start->parent()->is(Beyond->parent()),
"The two Pos's are not from the same Seq!");
for(posA P = (posA&)Start->makeCopy(0);
!Beyond->isEqual(P.guts()); ++P)
{assumed(P(), "Second Pos is not after the first!");
characterA C = characterA::isa(*P);
if(!!C)
End = End->insertAfter(C.guts());
}
}
}
deref();
}
dlMinStringG::
dlMinStringG (const char* S, int IsConst)
:minStringG(IsConst), Header(0), End(0), PosList(0)
{ref();
{End = Header = new dlcNodeP;
for(const char* P = S; *P; ++P)
{characterA C = characterA::make(*P);
End = End->insertAfter(C.guts());
}
}
deref();
}
dlMinStringG::
dlMinStringG (const char* Start, const char* Beyond, int IsConst)
:minStringG(IsConst), Header(0), End(0), PosList(0)
{ref();
{End = Header = new dlcNodeP;
if(!Beyond)
{for(const char* P = Start; *P; ++P)
{characterA C = characterA::make(*P);
End = End->insertAfter(C.guts());
}
}
else
{ensure(Beyond > Start, "Second Ptr is not after the first!");
for(const char* P = Start; (Beyond != P); ++P)
{characterA C = characterA::make(*P);
End = End->insertAfter(C.guts());
}
}
}
deref();
}
dlMinStringG::
dlMinStringG (int Uppercase, const seqG* S, int IsConst)
:minStringG(IsConst), Header(0), End(0), PosList(0)
{ref();
{End = Header = new dlcNodeP;
for(posA P = S->makePos(0, 0); P(); ++P)
{characterA C = characterA::isa(*P);
if(!!C)
End = End->insertAfter(Uppercase ? C.guts()->uppercase()
: C.guts()->lowercase());
}
}
deref();
}
dlMinStringG::
dlMinStringG (int Uppercase, const posG* Start, const posG* Beyond,
int IsConst)
:minStringG(IsConst), Header(0), End(0), PosList(0)
{ref();
{End = Header = new dlcNodeP;
if(!Beyond)
{for(posA P = (posA&)Start->makeCopy(0); P(); ++P)
{characterA C = characterA::isa(*P);
if(!!C)
End = End->insertAfter(Uppercase ? C.guts()->uppercase()
: C.guts()->lowercase());
}
}
else
{ensure(Start->parent()->is(Beyond->parent()),
"The two Pos's are not from the same Seq!");
for(posA P = (posA&)Start->makeCopy(0);
!Beyond->isEqual(P.guts()); ++P)
{assumed(P(), "Second Pos is not after the first!");
characterA C = characterA::isa(*P);
if(!!C)
End = End->insertAfter(Uppercase ? C.guts()->uppercase()
: C.guts()->lowercase());
}
}
}
deref();
}
dlMinStringG::
dlMinStringG (int Uppercase, const char* S, int IsConst)
:minStringG(IsConst), Header(0), End(0), PosList(0)
{ref();
{End = Header = new dlcNodeP;
for(const char* P = S; *P; ++P)
{characterA C = characterA::make(*P);
End = End->insertAfter(Uppercase ? C.guts()->uppercase()
: C.guts()->lowercase());
}
}
deref();
}
dlMinStringG::
dlMinStringG (int Uppercase, const char* Start, const char* Beyond, int IsConst)
:minStringG(IsConst), Header(0), End(0), PosList(0)
{ref();
{End = Header = new dlcNodeP;
if(!Beyond)
{for(const char* P = Start; *P; ++P)
{characterA C = characterA::make(*P);
End = End->insertAfter(Uppercase ? C.guts()->uppercase()
: C.guts()->lowercase());
}
}
else
{ensure(Beyond > Start, "Second Ptr is not after the first!");
for(const char* P = Start; (Beyond != P); ++P)
{characterA C = characterA::make(*P);
End = End->insertAfter(Uppercase ? C.guts()->uppercase()
: C.guts()->lowercase());
}
}
}
deref();
}
dlMinStringG::
~dlMinStringG ()
{ref();
{while(Header->next())
Header->deleteNext();
delete Header;
}
deref();
}
// oathCore Operations //////////
void dlMinStringG::
export (exportP& X) const
{X.writeType(TypeName);
int Count = count();
X.stream() << Count << ' ';
if(Count)
dlMinStringG::ostreamInsertion(X.stream());
}
objA dlMinStringG::
import (importP& M)
{int Count;
M.stream() >> Count;
M.stream().get();
if(Count)
{dlcNodeP * Header = new dlcNodeP;
dlcNodeP * End = Header;
for(int I = 0; I < Count; ++I)
{characterA Tmp = characterA::make(M.stream().get());
End->Next = new dlcNodeP (End, 0, Tmp.guts());
End = End->Next;
}
return new dlMinStringG (Header, End);
}
else
return new dlMinStringG ();
}
// obj Operations //////////
int dlMinStringG::
isEqual (const objG* O) const
{if(is(O))
return TRUE;
if(!O->isType(stringG::Type))
return FALSE;
const stringG* S = (const stringG*)O;
posA Pthis = makePos(0, 0);
posA PS = S->makePos(0, 0);
while(Pthis())
{if(PS.isPastEnd())
return FALSE;
if(!(*Pthis).is(*PS))
return FALSE;
++Pthis;
++PS;
}
return (PS.isPastEnd() ? TRUE : FALSE);
}
objA dlMinStringG::
makeCopy (int MakeConst) const
{if(MakeConst)
return new pMinStringG (this);
else
{dlcNodeP * NewHead = new dlcNodeP;
dlcNodeP * NewEnd = NewHead;
for(dlcNodeP * P = Header; P->next(); P = P->next())
NewEnd = NewEnd->insertAfter(P->nextObj().guts());
return new dlMinStringG (NewHead, NewEnd);
}
}
// bag Operations //////////
int dlMinStringG::
isEmpty () const
{return !Header->next();}
int dlMinStringG::
count () const
{int C = 0;
for(dlcNodeP *N = Header->next(); N; N = N->next())
C++;
return C;
}
int dlMinStringG::
contains (const objG* O) const
{if(!O->isImplementedAs(characterG::Type))
return FALSE;
for(dlcNodeP *N = Header->next(); N; N = N->next())
if(O->is(N->thisObj().guts()))
return TRUE;
return FALSE;
}
int dlMinStringG::
containsEqual (const objG* O) const
{if(!O->isImplementedAs(characterG::Type))
return FALSE;
for(dlcNodeP *N = Header->next(); N; N = N->next())
if(O->is(N->thisObj().guts()))
return TRUE;
return FALSE;
}
int dlMinStringG::
canContain (const objG* O) const
{return O->isImplementedAs(characterG::Type);}
void dlMinStringG::
insert (const objG* O)
{if(O->isImplementedAs(characterG::Type))
End = End->insertAfter((characterG*)O);
}
void dlMinStringG::
append (const bagG* B)
{B->applyX(callSelf, this);}
void dlMinStringG::
apply (void (*F)(objA)) const
{for(dlcNodeP *N = Header->next(); N; N = N->next())
F(N->thisObj());
}
bagG* dlMinStringG::
applyX (objA (*F)(objA), bagG* B) const
{for(dlcNodeP *N = Header->next(); N; N = N->next())
{objA O = F(N->thisObj());
B->insert(O.guts());
}
return B;
}
bagG* dlMinStringG::
applyX (bagA (*F)(objA), bagG* B) const
{for(dlcNodeP *N = Header->next(); N; N = N->next())
{bagA O = F(N->thisObj());
B->append(O.guts());
}
return B;
}
// queue Operations //////////
const objG* dlMinStringG::
remove ()
{assumed(!isEmpty(), "operator>>() attempted on an empty Queue!");
adjustPosList(Header->next(), Header);
const objG* O = Header->nextObj().guts();
if(End == Header->next())
End = Header;
Header->deleteNext();
return O;
}
// seq Operations //////////
const objG* dlMinStringG::
subscript (int I) const
{dlcNodeP* N = internalPosition(I);
assumed(N->next(), "Indexed beyond end of Seq!");
return N->nextObj().guts();
}
const objG* dlMinStringG::
subscript (const posG* P) const
{ensure(!P->isNil() && is(P->parent()), "Position not from this seq!");
return ((dlMinStringPosG*)P)->Prev->nextObj().guts();
}
seqA dlMinStringG::
makeSeq (const posG* Start, const posG* Beyond, int MakeConst) const
{return MakeConst ? (seqG*)new pMinStringG (Start, Beyond)
: (seqG*)new dlMinStringG (Start, Beyond);}
seqA dlMinStringG::
makeSeq (int Start, int Beyond, int MakeConst) const
{posA S = makePos(Start, TRUE);
posA B = makePos(Beyond, TRUE);
return MakeConst ? (seqG*)new pMinStringG (S.guts(), B.guts())
: (seqG*)new dlMinStringG (S.guts(), B.guts());
}
// fifoQueue Operations //////////
// deq Operations //////////
void dlMinStringG::
pushFront (const objG* O)
{if(O->isImplementedAs(characterG::Type))
{Header->insertAfter((characterG*)O);
if(Header == End)
End = Header->next();
}
}
const objG* dlMinStringG::
pullEnd ()
{assumed(!isEmpty(), "pullEndX() attempted on an empty Queue!");
adjustPosList(End, End->prev());
const objG* O = End->thisObj().guts();
End = End->prev();
End->deleteNext();
return O;
}
// list Operations //////////
void dlMinStringG::
insertList (const listPosG* P, const objG* O)
{ensure(!P->isNil() && is(P->parent()), "Position not from this seq!");
if(O->isImplementedAs(characterG::Type))
{((dlMinStringPosG*)P)->Prev->insertAfter((characterG*)O);
if(((dlMinStringPosG*)P)->Prev == End)
End = End->next();
}
}
const objG* dlMinStringG::
removeList (const listPosG* P)
{ensure(!P->isNil() && is(P->parent()), "Position not from this seq!");
dlcNodeP* N = ((dlMinStringPosG*)P)->Prev->next();
assumed(N, "Attempt to delete past end with dlMinStringLT::extractX(P,O)!");
adjustPosList(N, ((dlMinStringPosG*)P)->Prev);
const objG* O = ((dlMinStringPosG*)P)->Prev->nextObj().guts();
if(N == End)
End = End->prev();
((dlMinStringPosG*)P)->Prev->deleteNext();
return O;
}
// string Operations //////////
const char * dlMinStringG::
charStar () const
{int Count = count();
char * S = new char[Count + 1];
char * Stop = S;
for(dlcNodeP* P = Header; P->next(); P = P->next())
{if(*Stop = P->nextObj().value())
Stop++;
else
break;
}
*Stop = '\0';
return S;
}
void dlMinStringG::
charStarX (char * C, int N) const
{int Count = count();
Count = ((N < Count) ? N : Count);
dlcNodeP* P = Header;
for(int I = 0; I < Count; I++)
{C[I] = P->nextObj().value();
P = P->next();
}
}
int dlMinStringG::
hash () const // K = 4
{int H = 0;
for(dlcNodeP *P = Header->next(); P; P = P->next())
H = (H << 2) + P->thisObj().value();
return abs(H);
}
int dlMinStringG::
hash (int K) const
{if(K == 4)
return dlMinStringG::hash();
else
{int H = 0;
for(dlcNodeP *P = Header->next(); P; P = P->next())
H = (K * H) + P->thisObj().value();
return abs(H);
}
}
int dlMinStringG::
hashLower () const // K = 4
{int H = 0;
for(dlcNodeP *P = Header->next(); P; P = P->next())
H = (H << 2) + tolower(P->thisObj().value());
return abs(H);
}
int dlMinStringG::
hashLower (int K) const
{if(K == 4)
return dlMinStringG::hash();
else
{int H = 0;
for(dlcNodeP *P = Header->next(); P; P = P->next())
H = (K * H) + tolower(P->thisObj().value());
return abs(H);
}
}
int dlMinStringG::
hashUpper () const // K = 4
{int H = 0;
for(dlcNodeP *P = Header->next(); P; P = P->next())
H = (H << 2) + toupper(P->thisObj().value());
return abs(H);
}
int dlMinStringG::
hashUpper (int K) const
{if(K == 4)
return dlMinStringG::hash();
else
{int H = 0;
for(dlcNodeP *P = Header->next(); P; P = P->next())
H = (K * H) + toupper(P->thisObj().value());
return abs(H);
}
}
int dlMinStringG::
isEqual (const char * PS) const
{stringPosA Pthis = (stringPosA&)makePos(0, 0);
while(Pthis())
{if(!*PS)
return FALSE;
if((*Pthis).value() != *PS)
return FALSE;
++Pthis;
++PS;
}
return (!*PS ? TRUE : FALSE);
}
int dlMinStringG::
isEqual (const stringPosG* Start, const stringPosG* Beyond) const
{assumed(!Start->isNil() && !Beyond->isNil()
&& Start->parent()->is(Beyond->parent()),
"The two Pos's are not from the same String!");
stringPosA Pthis = (stringPosA&)makePos(0, 0);
stringPosA PS = (stringPosA&)Start->makeCopy(0);
stringPosA PE = Beyond;
while(Pthis())
{if(PE == PS)
return FALSE;
if(*Pthis != *PS)
return FALSE;
++Pthis;
++PS;
}
return (PE == PS ? TRUE : FALSE);
}
int dlMinStringG::
isEqualAnyCase (const stringG* S) const
{if(S->isNil())
return FALSE;
stringPosA Pthis = (stringPosA&)makePos(0, 0);
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(Pthis())
{if(PS.isPastEnd())
return FALSE;
if((*Pthis).lowercase() != (*PS).lowercase())
return FALSE;
++Pthis;
++PS;
}
return (PS.isPastEnd() ? TRUE : FALSE);
}
int dlMinStringG::
isEqualAnyCase (const char * PS) const
{stringPosA Pthis = (stringPosA&)makePos(0, 0);
while(Pthis())
{if(!*PS)
return FALSE;
if((*Pthis).lowercase().value() != tolower(*PS))
return FALSE;
++Pthis;
++PS;
}
return (!*PS ? TRUE : FALSE);
}
int dlMinStringG::
isEqualAnyCase (const stringPosG* Start, const stringPosG* Beyond) const
{assumed(!Start->isNil() && !Beyond->isNil()
&& Start->parent()->is(Beyond->parent()),
"The two Pos's are not from the same String!");
stringPosA Pthis = (stringPosA&)makePos(0, 0);
stringPosA PS = (stringPosA&)Start->makeCopy(0);
stringPosA PE = Beyond;
while(Pthis())
{if(PE == PS)
return FALSE;
if((*Pthis).lowercase() != (*PS).lowercase())
return FALSE;
++Pthis;
++PS;
}
return (PE == PS ? TRUE : FALSE);
}
int dlMinStringG::
lessThan (const stringG* S) const
{if(is(S))
return FALSE;
stringPosA Pthis = (stringPosA&)makePos(0, 0);
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(Pthis())
{if(PS.isPastEnd())
return FALSE;
characterA Cthis = *Pthis;
characterA CS = *PS;
if(Cthis < CS)
return TRUE;
if(Cthis > CS)
return FALSE;
++Pthis;
++PS;
}
return (PS.isPastEnd() ? FALSE : TRUE);
}
int dlMinStringG::
moreThan (const stringG* S) const
{if(is(S))
return FALSE;
stringPosA Pthis = (stringPosA&)makePos(0, 0);
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(PS())
{if(Pthis.isPastEnd())
return FALSE;
characterA Cthis = *Pthis;
characterA CS = *PS;
if(Cthis > CS)
return TRUE;
if(Cthis < CS)
return FALSE;
++Pthis;
++PS;
}
return (Pthis.isPastEnd() ? FALSE : TRUE);
}
ostream& dlMinStringG::
ostreamInsertion (ostream& F) const
{for(stringPosA P = (stringPosA&)makePos(0, 0); P(); ++P)
F << *P;
return F;
}
istream& dlMinStringG::
istreamExtraction (istream& F)
{char C;
while(F.get(C))
stringInsert(C);
return F;
}
void dlMinStringG::
stringInsert (const characterG* C)
{End = End->insertAfter(C);}
void dlMinStringG::
stringInsert (char C)
{End = End->insertAfter(characterA::make(C).guts());}
void dlMinStringG::
stringAppend (const stringG* S)
{for(stringPosA P = (stringPosA&)S->makePos(0, 0); P(); ++P)
End = End->insertAfter((*P).guts());
}
void dlMinStringG::
stringAppend (const char* S)
{for(; *S; S++)
End = End->insertAfter(characterA::make(*S).guts());
}
stringG* dlMinStringG::
applyStringX (characterA (*F)(characterA), stringG* S) const
{for(dlcNodeP *N = Header->next(); N; N = N->next())
{characterA C = F(N->thisObj());
S->stringInsert(C.guts());
}
return S;
}
stringG* dlMinStringG::
applyStringX (stringA (*F)(characterA), stringG* S) const
{for(dlcNodeP *N = Header->next(); N; N = N->next())
{stringA C = F(N->thisObj());
S->stringAppend(C.guts());
}
return S;
}
void dlMinStringG::
lowercase ()
{ensure(FALSE, "Sorry, not implemented!");}
void dlMinStringG::
uppercase ()
{ensure(FALSE, "Sorry, not implemented!");}
stringA dlMinStringG::
makeLower (int MakeConst) const
{return MakeConst ? (stringG*)new pMinStringG (FALSE, this)
: (stringG*)new dlMinStringG (FALSE, this);
}
stringA dlMinStringG::
makeUpper (int MakeConst) const
{return MakeConst ? (stringG*)new pMinStringG (TRUE, this)
: (stringG*)new dlMinStringG (TRUE, this);
}
// dlMinString Operations //////////
dlcNodeP * dlMinStringG::
internalPosition (int I) const
{if(!I)
return Header;
dlcNodeP* N = Header;
for(int J = 0; (J < I) && N->next(); J++)
N = N->next();
return N;
}
void dlMinStringG::
adjustPosList (dlcNodeP * CurrentPrev, dlcNodeP * NewPrev)
{dlMinStringPosG * Pos = PosList;
while(Pos)
{if(Pos->Prev == CurrentPrev)
Pos->Prev = NewPrev;
Pos = Pos->NextPos;
}
}
/////////////////////////////////////////////////////////////////////////////
// pMinStringG Outlines
OUTLINES_G(pMinString, minString)
// Constructors //////////
pMinStringG::
pMinStringG ()
:minStringG(TRUE), Count(0), String(0)
{ref();
{String = new char[1];
*String = '\0';
}
deref();
}
pMinStringG::
pMinStringG (const seqG* S)
:minStringG(TRUE), Count(0), String(0)
{ref();
{minStringA Temp = minStringA::make(S);
Count = Temp.count();
String = new char[Count+1];
characterA C;
char * End = String;
for(stringPosA P = Temp.makePos(); P(); ++P)
*End++ = (*P).value();
*End = '\0';
}
deref();
}
pMinStringG::
pMinStringG (const posG* Start, const posG* Beyond)
:minStringG(TRUE), Count(0), String(0)
{ref();
{minStringA Temp = minStringA::make(Start, Beyond);
Count = Temp.count();
String = new char[Count+1];
characterA C;
char * End = String;
for(stringPosA P = Temp.makePos(); P(); ++P)
*End++ = (*P).value();
*End = '\0';
}
deref();
}
pMinStringG::
pMinStringG (const char * S) // NUL-terminated string
:minStringG(TRUE), Count(strlen(S)), String(0)
{ref();
{String = new char[Count+1];
strcpy(String, S);
}
deref();
}
pMinStringG::
pMinStringG (const char * Start, const char * Beyond)
:minStringG(TRUE), Count(Beyond - Start), String(0)
{ref();
{String = new char[Count+1];
memcpy(String, Start, Count);
String[Count] = '\0';
}
deref();
}
pMinStringG::
pMinStringG (int Uppercase, const seqG* S)
:minStringG(TRUE), Count(S->count()), String(0)
{ref();
{minStringA Temp = minStringA::make(S);
Count = Temp.count();
String = new char[Count+1];
characterA C;
char * End = String;
for(stringPosA P = Temp.makePos(); P(); ++P)
{if(Uppercase)
*End++ = (*P).uppercase().value();
else
*End++ = (*P).lowercase().value();
}
*End = '\0';
}
deref();
}
pMinStringG::
pMinStringG (int Uppercase, const posG* Start, const posG* Beyond)
:minStringG(TRUE), Count(0), String(0)
{ref();
{minStringA Temp = minStringA::make(Start, Beyond);
Count = Temp.count();
String = new char[Count+1];
characterA C;
char * End = String;
for(stringPosA P = Temp.makePos(); P(); ++P)
{if(Uppercase)
*End++ = (*P).uppercase().value();
else
*End++ = (*P).lowercase().value();
}
*End = '\0';
}
deref();
}
pMinStringG::
pMinStringG (int Uppercase, const char * S)
:minStringG(TRUE), Count(strlen(S)), String(0)
{ref();
{String = new char[Count+1];
for(int I = 0; I < Count; I++)
String[I] = (Uppercase ? toupper(S[I]) : tolower(S[I]));
}
deref();
}
pMinStringG::
pMinStringG (int Uppercase, const char * Start, const char * Beyond)
:minStringG(TRUE), Count(Beyond - Start), String(0)
{ref();
{String = new char[Count+1];
for(int I = 0; I < Count; I++)
String[I] = (Uppercase ? toupper(Start[I]) : tolower(Start[I]));
}
deref();
}
// oathCore Operations //////////
void pMinStringG::
export (exportP& X) const
{X.writeType(TypeName);
int Count = count();
X.stream() << Count << ' ';
if(Count)
X.stream().write(String, Count);
}
objA pMinStringG::
import (importP& M)
{int Count;
M.stream() >> Count;
M.stream().get();
if(Count)
{char* String = new char [Count];
M.stream().read(String, Count);
return new pMinStringG (String);
}
else
return new pMinStringG ();
}
// obj Operations //////////
int pMinStringG::
isEqual (const objG* O) const
{if(is(O))
return TRUE;
else if(O->isImplementedAs(Type))
{const pMinStringG* PS = (pMinStringG*)O;
return (Count == PS->Count) && !memcmp(String, PS->String, Count);
}
else if(O->isType(stringG::Type))
{const stringG* S = (stringG*)O;
posA Pthis = makePos(0, 0);
posA PS = S->makePos(0, 0);
while(Pthis())
{if(PS.isPastEnd())
return FALSE;
if(!(*Pthis).is(*PS))
return FALSE;
++Pthis;
++PS;
}
return (PS.isPastEnd() ? TRUE : FALSE);
}
else
return FALSE;
}
// bag Operations //////////
int pMinStringG::
isEmpty () const
{return !Count;}
int pMinStringG::
count () const
{return Count;}
int pMinStringG::
contains (const objG* O) const
{return O->isImplementedAs(characterG::Type)
&& (int)(memchr(String, ((characterG*)O)->value(), Count));
}
int pMinStringG::
containsEqual (const objG* O) const
{return O->isImplementedAs(characterG::Type)
&& (int)(memchr(String, ((characterG*)O)->value(), Count));
}
int pMinStringG::
canContain (const objG* O) const
{return O->isImplementedAs(characterG::Type);}
void pMinStringG::
insert (const objG*)
{ensure(FALSE, "Attempted to modify a const string!");}
void pMinStringG::
append (const bagG*)
{ensure(FALSE, "Attempted to modify a const string!");}
void pMinStringG::
apply (void (*F)(objA)) const
{for(const char *N = String; *N; N++)
F(characterA::make(*N));
}
bagG* pMinStringG::
applyX (objA (*F)(objA), bagG* B) const
{for(const char *N = String; *N; N++)
{objA O = F(characterA::make(*N));
B->insert(O.guts());
}
return B;
}
bagG* pMinStringG::
applyX (bagA (*F)(objA), bagG* B) const
{for(const char *N = String; *N; N++)
{bagA O = F(characterA::make(*N));
B->append(O.guts());
}
return B;
}
// queue Operations //////////
const objG* pMinStringG::
remove ()
{ensure(FALSE, "Attempted to modify a const string!");
return Nil;
}
// seq Operations //////////
const objG* pMinStringG::
subscript (int I) const
{assumed(I <= Count, "Indexed beyond end of String!");
return characterA::make(String[I]).guts();
}
const objG* pMinStringG::
subscript (const posG* P) const
{ensure(is(P->parent()), "Position not from this String!");
return P->indirection();
}
seqA pMinStringG::
makeSeq (const posG* Start, const posG* Beyond, int MakeConst) const
{ensure(is(Start->parent()), "pos is not from this seq!");
return MakeConst ? (seqG*)new pMinStringG (Start, Beyond)
: (seqG*)new dlMinStringG (Start, Beyond);
}
seqA pMinStringG::
makeSeq (int Start, int Beyond, int MakeConst) const
{ensure(Start <= Count, "Start is out of range!");
return MakeConst ? (seqG*)new pMinStringG (internalPosition(Start),
internalPosition(Beyond))
: (seqG*)new dlMinStringG (internalPosition(Start),
internalPosition(Beyond));
}
// fifoQueue Operations //////////
// deq Operations //////////
void pMinStringG::
pushFront (const objG*)
{ensure(FALSE, "Attempted to modify a const string!");}
const objG* pMinStringG::
pullEnd ()
{ensure(FALSE, "Attempted to modify a const string!");
return Nil;
}
// list Operations //////////
void pMinStringG::
insertList (const listPosG*, const objG*)
{ensure(FALSE, "Attempted to modify a const string!");}
const objG* pMinStringG::
removeList (const listPosG*)
{ensure(FALSE, "Attempted to modify a const string!");
return Nil;
}
// string Operations //////////
const char * pMinStringG::
charStar () const
{char * RV = new char [Count + 1];
memcpy(RV, String, Count+1);
return RV;
}
void pMinStringG::
charStarX (char * C, int N) const
{memcpy(C, String, (N <= Count ? N : Count+1));}
int pMinStringG::
hash () const // K = 4
{int H = 0;
for(int I = 0; I < Count; I++)
H = (H << 2) + String[I];
return abs(H);
}
int pMinStringG::
hash (int K) const
{if(K == 4)
return pMinStringG::hash();
else
{int H = 0;
for(int I = 0; I < Count; I++)
H = (K * H) + String[I];
return abs(H);
}
}
int pMinStringG::
hashLower () const // K = 4
{int H = 0;
for(int I = 0; I < Count; I++)
H = (H << 2) + tolower(String[I]);
return abs(H);
}
int pMinStringG::
hashLower (int K) const
{if(K == 4)
return pMinStringG::hashLower();
else
{int H = 0;
for(int I = 0; I < Count; I++)
H = (K * H) + tolower(String[I]);
return abs(H);
}
}
int pMinStringG::
hashUpper () const // K = 4
{int H = 0;
for(int I = 0; I < Count; I++)
H = (H << 2) + toupper(String[I]);
return abs(H);
}
int pMinStringG::
hashUpper (int K) const
{if(K == 4)
return pMinStringG::hashUpper();
else
{int H = 0;
for(int I = 0; I < Count; I++)
H = (K * H) + toupper(String[I]);
return abs(H);
}
}
int pMinStringG::
isEqual (const char * C) const
{return (Count == strlen(C)) && !memcmp(String, C, Count);}
int pMinStringG::
isEqual (const stringPosG* Start, const stringPosG* Beyond) const
{posA Pthis = makePos(0, 0);
posA PS = (posA&)Start->makeCopy(0);
while(Pthis())
{if(Beyond->isEqual(PS.guts()))
return FALSE;
if(*Pthis != *PS)
return FALSE;
++Pthis;
++PS;
}
return (Beyond->isEqual(PS.guts()) ? TRUE : FALSE);
}
int pMinStringG::
isEqualAnyCase (const stringG* S) const
{stringPosA Pthis = (stringPosA&)makePos(0, 0);
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(Pthis())
{if(PS.isPastEnd())
return FALSE;
if((*Pthis).lowercase() != (*PS).lowercase())
return FALSE;
++Pthis;
++PS;
}
return (PS.isPastEnd() ? TRUE : FALSE);
}
int pMinStringG::
isEqualAnyCase (const char * PS) const // can be faster
{stringPosA Pthis = (stringPosA&)makePos(0, 0);
while(Pthis())
{if(!*PS)
return FALSE;
if(((*Pthis).lowercase().value() != tolower(*PS)))
return FALSE;
++Pthis;
++PS;
}
return (!*PS ? TRUE : FALSE);
}
int pMinStringG::
isEqualAnyCase (const stringPosG* Start, const stringPosG* Beyond) const
{stringPosA Pthis = (stringPosA&)makePos(0, 0);
stringPosA PS = (stringPosA&)Start->makeCopy(0);
stringPosA PE = Beyond;
while(Pthis())
{if(PE == PS)
return FALSE;
if(((*Pthis).lowercase() != (*PS).lowercase()))
return FALSE;
++Pthis;
++PS;
}
return (PE == PS ? TRUE : FALSE);
}
int pMinStringG::
lessThan (const stringG* S) const
{if(is(S))
return FALSE;
if(S->isImplementedAs(Type))
return memcmp(String, ((pMinStringG*)S)->String, Count) < 0;
stringPosA Pthis = (stringPosA&)makePos(0, 0);
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(Pthis())
{if(PS.isPastEnd())
return FALSE;
characterA Cthis = *Pthis;
characterA CS = *PS;
if(Cthis < CS)
return TRUE;
if(Cthis > CS)
return FALSE;
++Pthis;
++PS;
}
if(Pthis.isPastEnd())
return (PS.isPastEnd() ? FALSE : TRUE);
}
int pMinStringG::
moreThan (const stringG* S) const
{if(is(S))
return FALSE;
if(S->isImplementedAs(Type))
return memcmp(String, ((pMinStringG*)S)->String, Count) > 0;
stringPosA Pthis = (stringPosA&)makePos(0, 0);
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(PS())
{if(Pthis.isPastEnd())
return FALSE;
characterA Cthis = *Pthis;
characterA CS = *PS;
if(Cthis > CS)
return TRUE;
if(Cthis < CS)
return FALSE;
++Pthis;
++PS;
}
if(PS.isPastEnd())
return (Pthis.isPastEnd() ? FALSE : TRUE);
}
ostream& pMinStringG::
ostreamInsertion (ostream& F) const
{return F.write(String, Count);}
istream& pMinStringG::
istreamExtraction (istream& F)
{ensure(FALSE, "Attempted to modify a const string!");
return F;
}
void pMinStringG::
stringInsert (const characterG*)
{ensure(FALSE, "Attempted to modify a const string!");}
void pMinStringG::
stringInsert (char)
{ensure(FALSE, "Attempted to modify a const string!");}
void pMinStringG::
stringAppend (const stringG*)
{ensure(FALSE, "Attempted to modify a const string!");}
inline void pMinStringG::
stringAppend (const char*)
{ensure(FALSE, "Attempted to modify a const string!");}
stringG* pMinStringG::
applyStringX (characterA (*F)(characterA), stringG* S) const
{for(const char *N = String; *N; N++)
{characterA C = F(characterA::make(*N));
S->stringInsert(C.guts());
}
return S;
}
stringG* pMinStringG::
applyStringX (stringA (*F)(characterA), stringG* S) const
{for(const char *N = String; *N; N++)
{stringA C = F(characterA::make(*N));
S->stringAppend(C.guts());
}
return S;
}
void pMinStringG::
lowercase ()
{ensure(FALSE, "Sorry, not implemented!");}
void pMinStringG::
uppercase ()
{ensure(FALSE, "Sorry, not implemented!");}
stringA pMinStringG::
makeLower (int MakeConst) const
{return MakeConst ? (stringG*)new pMinStringG (FALSE, this)
: (stringG*)new dlMinStringG (FALSE, this);
}
stringA pMinStringG::
makeUpper (int MakeConst) const
{return MakeConst ? (stringG*)new pMinStringG (TRUE, this)
: (stringG*)new dlMinStringG (TRUE, this);
}
/////////////////////////////////////////////////////////////////////////////
// minStringPos Outlines
OUTLINES(minStringPos, stringPos)
/////////////////////////////////////////////////////////////////////////////
// dlMinStringPosG Outlines
OUTLINES_G(dlMinStringPos, minStringPos)
// Constructors //////////
dlMinStringPosG::
dlMinStringPosG (const minStringG* iString, dlcNodeP* iPrev, int IsConst)
:minStringPosG(iString, IsConst),
Prev(iPrev), PrevPos(0), NextPos(parentT()->posList())
{if(NextPos)
NextPos->PrevPos = this;
parentT()->posList() = this;
}
dlMinStringPosG::
~dlMinStringPosG ()
{if(NextPos)
NextPos->PrevPos = PrevPos;
if(PrevPos)
PrevPos->NextPos = NextPos;
else
parentT()->posList() = NextPos;
}
// oathCore Operations //////////
void dlMinStringPosG::
export (exportP& X) const
{X.writeType(TypeName);
String.export(X);
int I = 0;
minStringPosA P = String.makePos();
while(((dlMinStringPosG*)(P.guts()))->Prev != Prev)
{++P; ++I;}
X.stream() << I << (isConst() ? ' ' : '\0');
}
objA dlMinStringPosG::
import (importP& M)
{minStringA S = minStringA::isa(objA::import(M));
int I;
M.stream() >> I;
char MakeConst = M.stream().get();
return S.makePos(I, MakeConst);
}
// obj Operations //////////
int dlMinStringPosG::
isEqual (const objG* O) const
{return O->isImplementedAs(Type)
&& String.guts()->is(((posG*)O)->parent())
&& Prev == ((dlMinStringPosG*)O)->Prev;
}
// pos Operations //////////
const objG* dlMinStringPosG::
indirection () const
{assumed(Prev->next(), "Access attempted past end of Sequence");
return Prev->nextObj().guts();
}
void dlMinStringPosG::
increment ()
{NOT_CONST();
if(Prev->next())
Prev = Prev->next();
}
void dlMinStringPosG::
increment (int I)
{NOT_CONST();
for(int J = 0; (J < I) && Prev->next(); J++)
Prev = Prev->next();
}
const objG* dlMinStringPosG::
find (const objG* O)
{NOT_CONST();
dlcNodeP * P = Prev;
dlcNodeP * N;
while(N = P->next())
{if(O->is(N->thisObj().guts()))
{Prev = P;
return O;
}
P = N;
}
return Nil;
}
const objG* dlMinStringPosG::
findEqual (const objG* O)
{NOT_CONST();
dlcNodeP * P = Prev;
dlcNodeP * N;
while(N = P->next())
{if(O->isEqual(N->thisObj().guts()))
{Prev = P;
return O;
}
P = N;
}
return Nil;
}
void dlMinStringPosG::
reset (const posG* P)
{NOT_CONST();
ensure(String.guts()->is(P->parent()), "Pos's not from same seq!");
Prev = ((dlMinStringPosG*)P)->Prev;
}
void dlMinStringPosG::
reset (int I)
{NOT_CONST();
Prev = parentT()->internalPosition(I);}
// listPos Operations //////////
void dlMinStringPosG::
decrement ()
{NOT_CONST();
if(Prev->prev())
Prev = Prev->prev();
}
void dlMinStringPosG::
decrement (int I)
{NOT_CONST();
for(int J = 0; (J < I) && Prev->prev(); J++)
Prev = Prev->prev();
}
// stringPos Operations //////////
const characterG* dlMinStringPosG::
charIndirection () const
{assumed(Prev->next(), "Access attempted past end of Sequence");
return Prev->nextObj().guts();
}
int dlMinStringPosG::
skipSpaces ()
{NOT_CONST();
if(isPastEnd() || !isspace(charIndirection()->value()))
return FALSE;
do {increment();
} while(!isPastEnd() && isspace(charIndirection()->value()));
return TRUE;
}
const stringG* dlMinStringPosG::
match (const stringG* S)
{NOT_CONST();
dlcNodeP * PT = Prev;
posA PS = S->makePos(0, 0);
//E&S//while(PS() && PT->next() && (*PS == PT->nextObj()))
while(PS() && PT->next())
{if(*PS != PT->nextObj())
break;
++PS;
PT = PT->next();
}
if(PS())
return stringG::Nil;
else
{Prev = PT;
return S;
}
}
int dlMinStringPosG::
canMatch (const stringG* S) const
{dlcNodeP * PT = Prev;
posA PS = S->makePos(0, 0);
//E&S//while(PS() && PT->next() && (*PS == PT->nextObj()))
while(PS() && PT->next())
{if(*PS != PT->nextObj())
break;
++PS;
PT = PT->next();
}
return !PS();
}
const stringG* dlMinStringPosG::
findString (const stringG* S)
{NOT_CONST();
dlcNodeP * PTStart = Prev;
posA PS = S->makePos(0, 0);
while(PTStart->next())
{dlcNodeP * PT = PTStart;
PS.reset();
//E&S//while(PS() && PT->next() && (*PS == PT->nextObj()))
while(PS() && PT->next())
{if(*PS != PT->nextObj())
break;
++PS;
PT = PT->next();
}
if(!PS())
{Prev = PTStart;
return S;
}
if(!PT->next())
break;
PTStart = PTStart->next();
}
return stringG::Nil;
}
const stringG* dlMinStringPosG::
findMatch (const stringG* S)
{NOT_CONST();
dlcNodeP * PTStart = Prev;
posA PS = S->makePos(0, 0);
while(PTStart->next())
{dlcNodeP * PT = PTStart;
PS.reset();
//E&S//while(PS() && PT->next() && (*PS == PT->nextObj()))
while(PS() && PT->next())
{if(*PS != PT->nextObj())
break;
++PS;
PT = PT->next();
}
if(!PS())
{Prev = PT;
return S;
}
if(!PT->next())
break;
PTStart = PTStart->next();
}
return stringG::Nil;
}
const stringG* dlMinStringPosG::
matchAnyCase (const stringG* S)
{NOT_CONST();
stringPosA PT = (stringPosA&)makeCopy(0);
stringPosA PS = (stringPosA&)S->makePos(0, 0);
//E&S//while(PS() && PT() && ((*PS).lowercase() == (*PT).lowercase()))
while(PS() && PT())
{if((*PS).lowercase() != (*PT).lowercase())
break;
++PS;
++PT;
}
if(PS())
return stringG::Nil;
else
{reset(PT.guts());
return S;
}
}
int dlMinStringPosG::
canMatchAnyCase (const stringG* S) const
{stringPosA PT = (stringPosA&)makeCopy(0);
stringPosA PS = (stringPosA&)S->makePos(0, 0);
//E&S//while(PS() && PT() && ((*PS).lowercase() == (*PT).lowercase()))
while(PS() && PT())
{if((*PS).lowercase() != (*PT).lowercase())
break;
++PS;
++PT;
}
return !PS();
}
const stringG* dlMinStringPosG::
findAnyCase (const stringG* S)
{NOT_CONST();
dlcNodeP * PTStart = Prev;
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(PTStart->next())
{dlcNodeP * PT = PTStart;
PS.reset();
while(PS() && PT->Next)
{if((*PS).lowercase() != PT->nextObj().lowercase())
break;
++PS;
PT = PT->next();
}
if(!PS())
{Prev = PTStart;
return S;
}
if(!PT->next())
break;
PTStart = PTStart->next();
}
return stringG::Nil;
}
const stringG* dlMinStringPosG::
findMatchAnyCase (const stringG* S)
{NOT_CONST();
dlcNodeP * PTStart = Prev;
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(PTStart->next())
{dlcNodeP * PT = PTStart;
PS.reset();
while(PS() && PT->Next)
{if((*PS).lowercase() != PT->nextObj().lowercase())
break;
++PS;
PT = PT->next();
}
if(!PS())
{Prev = PT;
return S;
}
if(!PT->next())
break;
PTStart = PTStart->next();
}
return stringG::Nil;
}
const char * dlMinStringPosG::
match (const char * PS)
{NOT_CONST();
dlcNodeP * PT = Prev;
while(*PS && PT->next())
{if(*PS != PT->nextObj().value())
return 0;
++PS;
PT = PT->next();
}
if(*PS)
return 0;
Prev = PT;
return PS;
}
int dlMinStringPosG::
canMatch (const char * PS) const
{dlcNodeP * PT = Prev;
while(*PS && PT->next())
{if(*PS != PT->nextObj().value())
return FALSE;
++PS;
PT = PT->next();
}
return !(*PS);
}
const char * dlMinStringPosG::
findString (const char * S)
{NOT_CONST();
dlcNodeP * PTStart = Prev;
while(PTStart->next())
{dlcNodeP * PT = PTStart;
const char * PS = S;
while(*PS && PT->next() && (*PS == PT->nextObj().value()))
{++PS;
PT = PT->next();
}
if(!*PS)
{Prev = PTStart;
return S;
}
if(!PT->next())
return 0;
PTStart = PTStart->next();
}
return 0;
}
const char * dlMinStringPosG::
findMatch (const char * S)
{NOT_CONST();
dlcNodeP * PTStart = Prev;
while(PTStart->next())
{dlcNodeP * PT = PTStart;
const char * PS = S;
while(*PS && PT->next() && (*PS == PT->nextObj().value()))
{++PS;
PT = PT->next();
}
if(!*PS)
{Prev = PT;
return S;
}
if(!PT->next())
return 0;
PTStart = PTStart->next();
}
return 0;
}
const char * dlMinStringPosG::
matchAnyCase (const char *PS)
{NOT_CONST();
dlcNodeP * PT = Prev;
while(*PS && PT->next())
{if(tolower(*PS) != tolower(PT->nextObj().value()))
return 0;
++PS;
PT = PT->next();
}
if(*PS)
return 0;
Prev = PT;
return PS;
}
int dlMinStringPosG::
canMatchAnyCase (const char *PS) const
{dlcNodeP * PT = Prev;
while(*PS && PT->next())
{if(tolower(*PS) != tolower(PT->nextObj().value()))
return FALSE;
++PS;
PT = PT->next();
}
return !(*PS);
}
const char * dlMinStringPosG::
findAnyCase (const char * S)
{NOT_CONST();
dlcNodeP * PTStart = Prev;
while(PTStart->next())
{dlcNodeP * PT = PTStart;
const char * PS = S;
while(*PS && PT->next()
&& (tolower(*PS) == tolower(PT->nextObj().value())))
{++PS;
PT = PT->next();
}
if(!*PS)
{Prev = PTStart;
return S;
}
if(!PT->next())
return 0;
PTStart = PTStart->next();
}
return 0;
}
const char * dlMinStringPosG::
findMatchAnyCase (const char * S)
{NOT_CONST();
dlcNodeP * PTStart = Prev;
while(PTStart->next())
{dlcNodeP * PT = PTStart;
const char * PS = S;
while(*PS && PT->next()
&& (tolower(*PS) == tolower(PT->nextObj().value())))
{++PS;
PT = PT->next();
}
if(!*PS)
{Prev = PT;
return S;
}
if(!PT->next())
return 0;
PTStart = PTStart->next();
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// pMinStringPosG Outlines
OUTLINES_G(pMinStringPos, minStringPos)
// oathCore Operations //////////
void pMinStringPosG::
export (exportP& X) const
{X.writeType(TypeName);
String.export(X);
int I = 0;
minStringPosA P = String.makePos();
while(((pMinStringPosG*)(P.guts()))->Char != Char)
{++P; ++I;}
X.stream() << I << (isConst() ? ' ' : '\0');
}
objA pMinStringPosG::
import (importP& M)
{minStringA S = minStringA::isa(objA::import(M));
int I;
M.stream() >> I;
char MakeConst = M.stream().get();
return S.makePos(I, MakeConst);
}
// obj Operations //////////
int pMinStringPosG::
isEqual (const objG* O) const
{return O->isImplementedAs(Type) && Char == ((pMinStringPosG*)O)->Char;}
// pos Operations //////////
const objG* pMinStringPosG::
indirection () const
{ensure(!isPastEnd(), "Attempt to dereference past end of String!");
return characterA::make(*Char).guts();
}
void pMinStringPosG::
increment ()
{NOT_CONST();
if(Char < parentT()->internalPastEnd())
Char++;
}
void pMinStringPosG::
increment (int I)
{NOT_CONST();
Char += I;
if(Char > parentT()->internalPastEnd())
Char = parentT()->internalPastEnd();
}
const objG* pMinStringPosG::
find (const objG* O)
{NOT_CONST();
if(!O->isImplementedAs(characterG::Type))
return Nil;
const char * P = Char;
const char * PE = parentT()->internalPastEnd();
while(P != PE)
{if(*P == ((characterG*)O)->value())
{Char = P;
return O;
}
P++;
}
return objG::Nil;
}
const objG* pMinStringPosG::
findEqual (const objG* O)
{NOT_CONST();
if(!O->isImplementedAs(characterG::Type))
return Nil;
const char * P = Char;
const char * PE = parentT()->internalPastEnd();
while(P != PE)
{if(*P == ((characterG*)O)->value())
{Char = P;
return O;
}
P++;
}
return objG::Nil;
}
void pMinStringPosG::
reset (const posG* P)
{NOT_CONST();
ensure(parentT()->is(P->parent()), "Pos's are not from the same seq!");
Char = ((const pMinStringPosG*)P)->Char;
}
void pMinStringPosG::
reset (int I)
{NOT_CONST();
Char = parentT()->internalPosition(I);}
// listPos Operations //////////
void pMinStringPosG::
decrement ()
{NOT_CONST();
if(Char > parentT()->internalPosition(0))
Char--;
}
void pMinStringPosG::
decrement (int I)
{NOT_CONST();
Char -= I;
if(Char < parentT()->internalPosition(0))
Char = parentT()->internalPosition(0);
}
// stringPos Operations //////////
const characterG* pMinStringPosG::
charIndirection () const
{ensure(!isPastEnd(), "Attempt to dereference past end of String!");
return characterA::make(*Char).guts();
}
int pMinStringPosG::
skipSpaces ()
{NOT_CONST();
if(isPastEnd() || !isspace(*Char))
return FALSE;
do
{Char++;}
while(!isPastEnd() && isspace(*Char));
return TRUE;
}
const stringG* pMinStringPosG::
match (const stringG* S)
{NOT_CONST();
const char * PT = Char;
const char * PTPE = parentT()->internalPastEnd();
stringPosA PS = (stringPosA&)S->makePos(0, 0);
//E&S//while(PS() && (PT != PTPE) && (*PT == (*PS).value()))
while(PS() && (PT != PTPE))
{if(*PT != (*PS).value())
break;
++PS;
++PT;
}
if(PS())
return stringG::Nil;
else
{Char = PT;
return S;
}
}
int pMinStringPosG::
canMatch (const stringG* S) const
{const char * PT = Char;
const char * PTPE = parentT()->internalPastEnd();
stringPosA PS = (stringPosA&)S->makePos(0, 0);
//E&S//while(PS() && (PT != PTPE) && (*PT == (*PS).value()))
while(PS() && (PT != PTPE))
{if(*PT != (*PS).value())
break;
++PS;
++PT;
}
return !PS();
}
const stringG* pMinStringPosG::
findString (const stringG* S)
{NOT_CONST();
const char * PTStart = Char;
const char * PTPE = parentT()->internalPastEnd();
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(PTStart != PTPE)
{const char * PT = PTStart;
PS.reset();
//E&S//while(PS() && (PT != PTPE) && (*PT == (*PS).value()))
while(PS() && (PT != PTPE))
{if(*PT != (*PS).value())
break;
++PS;
++PT;
}
if(!PS())
{Char = PTStart;
return S;
}
if(PT == PTPE)
break;
++PTStart;
}
return stringG::Nil;
}
const stringG* pMinStringPosG::
findMatch (const stringG* S)
{NOT_CONST();
const char * PTStart = Char;
const char * PTPE = parentT()->internalPastEnd();
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(PTStart != PTPE)
{const char * PT = PTStart;
PS.reset();
//E&S//while(PS() && (PT != PTPE) && (*PT == (*PS).value()))
while(PS() && (PT != PTPE))
{if(*PT != (*PS).value())
break;
++PS;
++PT;
}
if(!PS())
{Char = PT;
return S;
}
if(PT == PTPE)
break;
++PTStart;
}
return stringG::Nil;
}
const stringG* pMinStringPosG::
matchAnyCase (const stringG* S)
{NOT_CONST();
const char * PT = Char;
const char * PTPE = parentT()->internalPastEnd();
stringPosA PS = (stringPosA&)S->makePos(0, 0);
//E&S//while(PS() && (PT != PTPE) && ((*PS).lowercase().value() == tolower(*PT)))
while(PS() && (PT != PTPE))
{if((*PS).lowercase().value() != tolower(*PT))
break;
++PS;
++PT;
}
if(PS())
return stringG::Nil;
else
{Char = PT;
return S;
}
}
int pMinStringPosG::
canMatchAnyCase (const stringG* S) const
{const char * PT = Char;
const char * PTPE = parentT()->internalPastEnd();
stringPosA PS = (stringPosA&)S->makePos(0, 0);
//E&S//while(PS() && (PT != PTPE) && ((*PS).lowercase().value() == tolower(*PT)))
while(PS() && (PT != PTPE))
{if((*PS).lowercase().value() != tolower(*PT))
break;
++PS;
++PT;
}
return !PS();
}
const stringG* pMinStringPosG::
findAnyCase (const stringG* S)
{NOT_CONST();
const char * PTStart = Char;
const char * PTPE = parentT()->internalPastEnd();
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(PTStart != PTPE)
{const char * PT = PTStart;
PS.reset();
//E&S//while(PS() && (PT != PTPE)
//E&S// && ((*PS).lowercase().value() != tolower(*PT)))
while(PS() && (PT != PTPE))
{if((*PS).lowercase().value() == tolower(*PT))
break;
++PS;
++PT;
}
if(!PS())
{Char = PTStart;
return S;
}
if(PT == PTPE)
break;
++PTStart;
}
return stringG::Nil;
}
const stringG* pMinStringPosG::
findMatchAnyCase (const stringG* S)
{NOT_CONST();
const char * PTStart = Char;
const char * PTPE = parentT()->internalPastEnd();
stringPosA PS = (stringPosA&)S->makePos(0, 0);
while(PTStart != PTPE)
{const char * PT = PTStart;
PS.reset();
//E&S//while(PS() && (PT != PTPE)
//E&S// && ((*PS).lowercase().value() != tolower(*PT)))
while(PS() && (PT != PTPE))
{if((*PS).lowercase().value() == tolower(*PT))
break;
++PS;
++PT;
}
if(!PS())
{Char = PT;
return S;
}
if(PT == PTPE)
break;
++PTStart;
}
return stringG::Nil;
}
const char * pMinStringPosG::
match (const char * PS)
{NOT_CONST();
const char * PT = Char;
const char * PTPE = parentT()->internalPastEnd();
while(*PS && (PT != PTPE))
{if(*PS != *PT)
return 0;
++PS; ++PT;
}
if(*PS)
return 0;
Char = PT;
return PS;
}
int pMinStringPosG::
canMatch (const char * PS) const
{const char * PT = Char;
const char * PTPE = parentT()->internalPastEnd();
while(*PS && (PT != PTPE))
{if(*PS != *PT)
return FALSE;
++PS; ++PT;
}
return !(*PS);
}
const char * pMinStringPosG::
findString (const char * S)
{NOT_CONST();
const char * PTStart = Char;
const char * PTPE = parentT()->internalPastEnd();
while(PTStart != PTPE)
{const char * PT = PTStart;
const char * PS = S;
while(*PS && (PT != PTPE) && (*PS == *PT))
{++PS; ++PT;}
if(!*PS)
{Char = PTStart;
return S;
}
if(PT == PTPE)
return 0;
++PTStart;
}
return 0;
}
const char * pMinStringPosG::
findMatch (const char * S)
{NOT_CONST();
const char * PTStart = Char;
const char * PTPE = parentT()->internalPastEnd();
while(PTStart != PTPE)
{const char * PT = PTStart;
const char * PS = S;
while(*PS && (PT != PTPE) && (*PS == *PT))
{++PS; ++PT;}
if(!*PS)
{Char = PT;
return S;
}
if(PT == PTPE)
return 0;
++PTStart;
}
return 0;
}
const char * pMinStringPosG::
matchAnyCase (const char *PS)
{NOT_CONST();
const char * PT = Char;
const char * PTPE = parentT()->internalPastEnd();
while(*PS && (PT != PTPE))
{if(tolower(*PS) != tolower(*PT))
return 0;
++PS; ++PT;
}
if(*PS)
return 0;
Char = PT;
return PS;
}
int pMinStringPosG::
canMatchAnyCase (const char *PS) const
{const char * PT = Char;
const char * PTPE = parentT()->internalPastEnd();
while(*PS && (PT != PTPE))
{if(tolower(*PS) != tolower(*PT))
return FALSE;
++PS; ++PT;
}
return !(*PS);
}
const char * pMinStringPosG::
findAnyCase (const char * S)
{NOT_CONST();
const char * PTStart = Char;
const char * PTPE = parentT()->internalPastEnd();
while(PTStart != PTPE)
{const char * PT = PTStart;
const char * PS = S;
while(*PS && (PT != PTPE) && (tolower(*PS) == tolower(*PT)))
{++PS; ++PT;}
if(!*PS)
{Char = PTStart;
return S;
}
if(PT == PTPE)
return 0;
++PTStart;
}
return 0;
}
const char * pMinStringPosG::
findMatchAnyCase (const char * S)
{NOT_CONST();
const char * PTStart = Char;
const char * PTPE = parentT()->internalPastEnd();
while(PTStart != PTPE)
{const char * PT = PTStart;
const char * PS = S;
while(*PS && (PT != PTPE) && (tolower(*PS) == tolower(*PT)))
{++PS; ++PT;}
if(!*PS)
{Char = PT;
return S;
}
if(PT == PTPE)
return 0;
++PTStart;
}
return 0;
}
//***************************************************************************